import React, {PropTypes, Component} from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import {observer} from 'mobx-react';

import "./index.scss";

import defaultAvatar from './img/default_tx.png';

export default class MainCmp extends Component {
    componentDidMount() {
    }

    _onError(e) {
        e.target.src = defaultAvatar;
    }

    render() {
        let item = this.props.data;

        let userUrl = '/community/user-details/' + item.id;

        return (
            <a target="_blank" href={userUrl}>
                <div className="vcg_common_userAvatar"><img
                    src={item.avatar instanceof Object ? item.avatar.a1 : item.avatar}
                    width="100%" onError={this._onError}/></div>
            </a>
        );
    }
}

MainCmp.propTypes = {
    data: PropTypes.object
};
